home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
Gfx
/
Edit
/
TSMorph
/
src
/
gui.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-30
|
32KB
|
1,003 lines
// TSMorph - Amiga Morphing program
// Copyright (C) © 1993 Topicsave Limited
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// mpaddock@cix.compulink.co.uk
/*
* Source machine generated by GadToolsBox V2.0
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : M J P
*/
// Note! This has had some source code changes after GadToolsBox generation
// including joining sources together, changing/adding gadgets
// and other source code (etc.) !!!!!
// Most changes should have comments attached
// include headers if not already done so
#ifndef TSMORPH_H
#include "TSMorph.h"
#endif
struct Screen *Scr = NULL;
UBYTE *PubScreenName = NULL;
APTR VisualInfo = NULL;
struct Window *TSMorphWnd = NULL;
struct Gadget *TSMorphGList = NULL;
struct Menu *TSMorphMenus = NULL;
struct MenuItem *TSMorphMenus1 = NULL;
struct IntuiMessage TSMorphMsg;
UWORD TSMorphZoom[4];
struct Gadget *TSMorphGadgets[17];
extern Class *initGet( void );
struct IClass *getClass = NULL;
struct _Object *getImage = NULL;
UWORD TSMorphLeft = 0;
UWORD TSMorphTop = 15;
UWORD TSMorphWidth = 262;
UWORD TSMorphHeight = 169;
UBYTE *TSMorphWdt = (UBYTE *)"TSMorph";
struct TextAttr *Font, Attr;
UWORD FontX, FontY;
UWORD OffX, OffY;
struct Window *GridRequestWnd = NULL;
struct Gadget *GridRequestGList = NULL;
struct IntuiMessage GridRequestMsg;
struct Gadget *GridRequestGadgets[4];
UWORD GridRequestLeft = 246;
UWORD GridRequestTop = 21;
UWORD GridRequestWidth = 121;
UWORD GridRequestHeight = 61;
UBYTE *GridRequestWdt = (UBYTE *)"Add Grid";
struct Window *ProgressWnd = NULL;
struct Gadget *ProgressGList = NULL;
struct IntuiMessage ProgressMsg;
struct Gadget *ProgressGadgets[3];
UWORD ProgressLeft = 190;
UWORD ProgressTop = 42;
UWORD ProgressWidth = 311;
UWORD ProgressHeight = 57;
UBYTE *ProgressWdt = (UBYTE *)"Loading Image";
struct NewMenu TSMorphNewMenu[] = {
NM_TITLE, (STRPTR)NULL, NULL, 0, NULL, NULL, // 0
NM_ITEM, (STRPTR)NULL, (STRPTR)NULL, 0, 0L, (APTR)TSMorphMenuNew, // 1
NM_ITEM, (STRPTR)NULL, (STRPTR)NULL, 0, 0L, (APTR)TSMorphMenuOpen, // 2
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL, // 3
NM_ITEM, (STRPTR)NULL, (STRPTR)NULL, 0, 0L, (APTR)TSMorphMenuSave, // 4
NM_ITEM, (STRPTR)NULL, (STRPTR)NULL, 0, 0L, (APTR)TSMorphMenuSaveAs, // 5
NM_ITEM, (STRPTR)NULL, NULL, 0, 0L, (APTR)TSMorphMenuDelete, // 6
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL, // 7
NM_ITEM, (STRPTR)NULL, NULL, 0, 0L, (APTR)TSMorphMenuAbout, // 8
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL, // 9
NM_ITEM, (STRPTR)NULL, (STRPTR)NULL, 0, 0L, (APTR)TSMorphMenuQuit, // 10
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL, // 11
NM_ITEM, (STRPTR)NULL,NULL,0,0L,(APTR)Preview, // 12
NM_ITEM, (STRPTR)NULL, (STRPTR)NULL, 0, 0L, (APTR)TSMorphMenuEditPoints, // 13
NM_TITLE, (STRPTR)NULL, NULL, 0, NULL, NULL, // 14
// Note this title has no items, these are based on the global settings menu
NM_END, NULL, NULL, 0, 0L, NULL };
UBYTE *SinglePictureLabels[] = {
(UBYTE *)"Morph",
(UBYTE *)"Warp",
(UBYTE *)"AMorph",
(UBYTE *)"AWarp",
NULL
};
UWORD TSMorphGTypes[] = {
GENERIC_KIND,
GENERIC_KIND,
NUMBER_KIND,
NUMBER_KIND,
GENERIC_KIND,
GENERIC_KIND,
BUTTON_KIND,
CYCLE_KIND,
GENERIC_KIND,
STRING_KIND,
STRING_KIND,
STRING_KIND,
STRING_KIND,
INTEGER_KIND,
INTEGER_KIND,
STRING_KIND,
TEXT_KIND,
};
struct NewGadget TSMorphNGad[] = {
239, 57, 20, 14, NULL, NULL, GD_GetFile1, 0, NULL, (APTR)GetFile1Clicked,
239, 75, 20, 14, NULL, NULL, GD_GetFile2, 0, NULL, (APTR)GetFile2Clicked,
72, 96, 37, 13, (UBYTE *)"Width", NULL, GD_Width, PLACETEXT_LEFT, NULL, NULL,
222, 96, 37, 13, (UBYTE *)"Height", NULL, GD_Height, PLACETEXT_LEFT, NULL, NULL,
239, 21, 20, 14, NULL, NULL, GD_GetFileOne, 0, NULL, (APTR)GetFileOneClicked,
239, 39, 20, 14, NULL, NULL, GD_GetFileTwo, 0, NULL, (APTR)GetFileTwoClicked,
2, 150, 257, 15, (UBYTE *)"Edit _Points...", NULL, GD_EditPoints, PLACETEXT_IN, NULL, (APTR)EditPointsClicked,
2, 114, 80, 14, NULL, NULL, GD_SinglePicture, 0, NULL, (APTR)SinglePictureClicked,
239, 132, 20, 14, NULL, NULL, GD_GetSaveName, 0, NULL, (APTR)GetSaveNameClicked,
72, 21, 163, 14, (UBYTE *)"File _One", NULL, GD_FileOne, PLACETEXT_LEFT, NULL, (APTR)FileOneClicked,
72, 39, 163, 14, (UBYTE *)"File _Two", NULL, GD_FileTwo, PLACETEXT_LEFT, NULL, (APTR)FileTwoClicked,
72, 57, 163, 14, (UBYTE *)"24 File _1", NULL, GD_File241, PLACETEXT_LEFT, NULL, (APTR)File241Clicked,
72, 75, 163, 14, (UBYTE *)"24 File _2", NULL, GD_File242, PLACETEXT_LEFT, NULL, (APTR)File242Clicked,
140, 114, 37, 14, (UBYTE *)"_Frames", NULL, GD_Frames, PLACETEXT_LEFT, NULL, (APTR)FramesClicked,
230, 114, 29, 14, (UBYTE *)"St_art", NULL, GD_Start, PLACETEXT_LEFT, NULL, (APTR)StartClicked,
72, 132, 163, 14, (UBYTE *)"_Name", NULL, GD_Name, PLACETEXT_LEFT, NULL, (APTR)NameClicked,
2, 4, 257, 13,NULL,NULL,GD_Help,0,NULL,NULL,
};
ULONG TSMorphGTags[] = {
(TAG_DONE),
(TAG_DONE),
(GTNM_Border), TRUE, (TAG_DONE),
(GTNM_Border), TRUE, (TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (GTCY_Labels), (ULONG)&SinglePictureLabels[0], (TAG_DONE),
(TAG_DONE),
(STRINGA_ExitHelp), TRUE, (GTST_MaxChars), 256, (STRINGA_Justification), (GACT_STRINGRIGHT), (GT_Underscore), '_', (TAG_DONE),
(STRINGA_ExitHelp), TRUE, (GTST_MaxChars), 256, (STRINGA_Justification), (GACT_STRINGRIGHT), (GT_Underscore), '_', (TAG_DONE),
(STRINGA_ExitHelp), TRUE, (GTST_MaxChars), 256, (STRINGA_Justification), (GACT_STRINGRIGHT), (GT_Underscore), '_', (TAG_DONE),
(STRINGA_ExitHelp), TRUE, (GTST_MaxChars), 256, (STRINGA_Justification), (GACT_STRINGRIGHT), (GT_Underscore), '_', (TAG_DONE),
(STRINGA_ExitHelp), TRUE, (GTIN_Number), 1, (GTIN_MaxChars), 10, (GT_Underscore), '_', (TAG_DONE),
(STRINGA_ExitHelp), TRUE, (GTIN_Number), 0, (GTIN_MaxChars), 10, (GT_Underscore), '_', (TAG_DONE),
(STRINGA_ExitHelp), TRUE, (GTST_MaxChars), 256, (STRINGA_Justification), (GACT_STRINGRIGHT), (GT_Underscore), '_', (TAG_DONE),
(GTTX_Border), TRUE, (TAG_DONE),
};
UWORD GridRequestGTypes[] = {
INTEGER_KIND,
INTEGER_KIND,
BUTTON_KIND,
BUTTON_KIND
};
struct NewGadget GridRequestNGad[] = {
76, 5, 40, 14, (UBYTE *)"_X Cells", NULL, GD_XCells, PLACETEXT_LEFT, NULL, (APTR)XCellsClicked,
76, 23, 40, 14, (UBYTE *)"_Y Cells", NULL, GD_YCells, PLACETEXT_LEFT, NULL, (APTR)YCellsClicked,
6, 43, 52, 13, (UBYTE *)"_OK", NULL, GD_OK, PLACETEXT_IN, NULL, (APTR)OKClicked,
64, 43, 52, 13, (UBYTE *)"_Cancel", NULL, GD_Cancel, PLACETEXT_IN, NULL, (APTR)CancelClicked
};
ULONG GridRequestGTags[] = {
(STRINGA_ExitHelp), TRUE, (GTIN_Number), 5, (GTIN_MaxChars), 3, (GT_Underscore), '_', (TAG_DONE),
(STRINGA_ExitHelp), TRUE, (GTIN_Number), 5, (GTIN_MaxChars), 3, (GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE)
};
UWORD ProgressGTypes[] = {
TEXT_KIND,
SLIDER_KIND,
SLIDER_KIND
};
struct NewGadget ProgressNGad[] = {
6, 6, 301, 13, NULL, NULL, GD_Mess, 0, NULL, NULL,
52, 26, 226, 11, (UBYTE *)"Pass", NULL, GD_Pass1, PLACETEXT_LEFT, NULL, NULL,
52, 43, 226, 11, (UBYTE *)"", NULL, GD_Pass2, PLACETEXT_LEFT, NULL, NULL
};
ULONG ProgressGTags[] = {
(GTTX_Border), TRUE, (TAG_DONE),
(GTSL_Max), 1, (GTSL_Min), 1, (GTSL_Level), 1, (GTSL_MaxLevelLen), 4, (GTSL_LevelFormat), (ULONG)"%3ld", (GTSL_LevelPlace), (PLACETEXT_RIGHT), (PGA_Freedom), LORIENT_HORIZ, (GA_RelVerify), TRUE, GA_Disabled,TRUE,(TAG_DONE),
(GTSL_Max), 999, (GTSL_Min), 0, (GTSL_MaxLevelLen), 4, (GTSL_LevelFormat), (ULONG)"%3ld", (GTSL_LevelPlace), (PLACETEXT_RIGHT), (PGA_Freedom), LORIENT_HORIZ, (GA_RelVerify), TRUE, GA_Disabled,TRUE,(TAG_DONE)
};
struct Rectangle Rect[17];
struct Rectangle GRect[4];
// The compute font sizing stuff has been changed
static UWORD ComputeX( UWORD value )
{
return(( UWORD )((( FontX * value ) + 3 ) / 6 ));
}
static UWORD ComputeY( UWORD value )
{
return(( UWORD )((( FontY * value ) + 5 ) / 10 ));
}
static void ComputeFont( UWORD width, UWORD height )
{
Font = &Attr;
Font->ta_Name = (STRPTR)Scr->RastPort.Font->tf_Message.mn_Node.ln_Name;
Font->ta_YSize = FontY = Scr->RastPort.Font->tf_YSize;
FontX = Scr->RastPort.Font->tf_XSize;
OffX = Scr->WBorLeft;
OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
if ( width && height ) {
if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
goto UseTopaz;
if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
goto UseTopaz;
}
return;
UseTopaz:
Font->ta_Name = (STRPTR)"topaz.font";
FontX = FontY = Font->ta_YSize = 8;
}
int SetupScreen( void )
{
if ( ! ( Scr = LockPubScreen( PubScreenName )))
return( 1L );
// Is screen low or hires (this check is not really the correct method
// but there does not appear to be a correct method - How does Workbench
// do it? But at least it gets the scroll bars right on lo-res screens,
// unlike MultiView!)
if (!(Scr->ViewPort.Modes & (HIRES | SUPERHIRES))) {
n=GS_LOWRES;
}
else {
n=GS_MEDRES;
}
ComputeFont( 0, 0 );
if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
return( 2L );
if ( ! ( getClass = initGet()))
return( 3L );
if ( ! ( getImage = NewObject( getClass, NULL, GT_VisualInfo, VisualInfo, TAG_DONE )))
return( 4L );
return( 0L );
}
void CloseDownScreen( void )
{
if ( getImage ) {
DisposeObject( getImage );
getImage = NULL;
}
if ( getClass ) {
FreeClass( getClass );
getClass = NULL;
}
if ( VisualInfo ) {
FreeVisualInfo( VisualInfo );
VisualInfo = NULL;
}
if ( Scr ) {
UnlockPubScreen( NULL, Scr );
Scr = NULL;
}
}
typedef int (FPTR(void));
int HandleTSMorphIDCMP( void )
{
struct IntuiMessage *m;
struct MenuItem *n;
int (*func)(void);
BOOL running = TRUE;
ULONG HNum;
while( m = GT_GetIMsg( TSMorphWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&TSMorphMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( TSMorphMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( TSMorphWnd );
GT_EndRefresh( TSMorphWnd, TRUE );
break;
case IDCMP_CLOSEWINDOW:
running = TSMorphCloseWindow();
break;
case IDCMP_MENUHELP:
running = TSMorphMenuHelp();
break;
case IDCMP_VANILLAKEY:
running = TSMorphVanillaKey();
break;
case IDCMP_RAWKEY:
running = TSMorphRawKey();
break;
case IDCMP_GADGETUP:
func = (FPTR *)(( struct Gadget * )TSMorphMsg.IAddress )->UserData;
running = func();
break;
// special case - settings use no GadToolsBox method
case IDCMP_MENUPICK:
while( TSMorphMsg.Code != MENUNULL ) {
n = ItemAddress( TSMorphMenus, TSMorphMsg.Code );
if (func = (FPTR *)(GTMENUITEM_USERDATA( n ))) {
running = func();
}
else {
HandleSettings(TSMorphMsg.Code,NULL);
}
TSMorphMsg.Code = n->NextSelect;
}
break;
// special case GadgetHelp
// see the amigaguide distribution for some of how
// this stuff works (i.e. do not ask me, I am not a developer)
case IDCMP_GADGETHELP:
if (TSMorphMsg.IAddress == NULL) {
HNum = 0;
}
else {
if (TSMorphMsg.IAddress == TSMorphWnd) {
HNum = H_IWindow;
}
else {
switch (((struct Gadget *)TSMorphMsg.IAddress)->GadgetType &0xf0) {
case GTYP_WDRAGGING:
HNum = H_IWindow;
break;
case GTYP_WUPFRONT:
HNum = H_IDepth;
break;
case GTYP_WDOWNBACK:
HNum = H_IZoom;
break;
case GTYP_CLOSE:
HNum = H_IClose;
break;
case 0:
switch (((struct Gadget *)TSMorphMsg.IAddress)->GadgetID) {
case GD_Help:
HNum = H_HelpGad;
break;
case GD_GetFile1:
HNum = H_G24File1;
break;
case GD_GetFile2:
HNum = H_G24File2;
break;
case GD_Width:
HNum = H_Width;
break;
case GD_Height:
HNum = H_Height;
break;
case GD_GetFileOne:
HNum = H_GFileOne;
break;
case GD_GetFileTwo:
HNum = H_GFileTwo;
break;
case GD_EditPoints:
HNum = H_EPoints;
break;
case GD_SinglePicture:
HNum = H_Single;
break;
case GD_GetSaveName:
HNum = H_GName;
break;
case GD_FileOne:
HNum = H_FileOne;
break;
case GD_FileTwo:
HNum = H_FileTwo;
break;
case GD_File241:
HNum = H_24File1;
break;
case GD_File242:
HNum = H_24File2;
break;
case GD_Frames:
HNum = H_Frames;
break;
case GD_Start:
HNum = H_Start;
break;
case GD_Name:
HNum = H_Name;
break;
default:
HNum = H_IWindow;
break;
}
break;
default:
HNum = H_IWindow;
break;
}
}
}
if (HNum) {
// display full or short help
if (GHelp) {
help(HNum);
}
else {
ihelp(HNum);
}
}
break;
}
}
return( (int) running );
}
int OpenTSMorphWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = TSMorphLeft, wtop, ww, wh;
TSMorphNewMenu[0].nm_Label = MyGetMsg(MSG_NM_PROJECT);
TSMorphNewMenu[1].nm_Label = MyGetMsg(MSG_NMT_NEW);
TSMorphNewMenu[1].nm_CommKey = MyGetMsg(MSG_NM_NEWPOINTS_S);
TSMorphNewMenu[2].nm_Label = MyGetMsg(MSG_NMT_OPEN);
TSMorphNewMenu[2].nm_CommKey = MyGetMsg(MSG_NM_OPENPOINTS_S);
TSMorphNewMenu[4].nm_Label = MyGetMsg(MSG_NM_SAVE);
TSMorphNewMenu[4].nm_CommKey = MyGetMsg(MSG_NM_SAVE_S);
TSMorphNewMenu[5].nm_Label = MyGetMsg(MSG_NM_SAVEAS);
TSMorphNewMenu[5].nm_CommKey = MyGetMsg(MSG_NM_SAVEAS_S);
TSMorphNewMenu[6].nm_Label = MyGetMsg(MSG_NMT_DELETE);
TSMorphNewMenu[8].nm_Label = MyGetMsg(MSG_NM_ABOUT);
TSMorphNewMenu[10].nm_Label = MyGetMsg(MSG_NM_QUIT);
TSMorphNewMenu[10].nm_CommKey = MyGetMsg(MSG_NM_QUIT_S);
TSMorphNewMenu[12].nm_Label = MyGetMsg(MSG_NM_PPREVIEW);
TSMorphNewMenu[13].nm_Label = MyGetMsg(MSG_NMT_EDITPOINTS);
TSMorphNewMenu[13].nm_CommKey = MyGetMsg(MSG_NMT_EDITPOINTS_S);
TSMorphNewMenu[14].nm_Label = MyGetMsg(MSG_NM_SETTINGS);
MyNewMenu[NM_PROJECT].nm_Label = MyGetMsg(MSG_NM_PROJECT);
MyNewMenu[NM_NEWPOINTS].nm_Label = MyGetMsg(MSG_NM_NEWPOINTS);
MyNewMenu[NM_NEWPOINTS].nm_CommKey = MyGetMsg(MSG_NM_NEWPOINTS_S);
MyNewMenu[NM_OPENPOINTS].nm_Label = MyGetMsg(MSG_NM_OPENPOINTS);
MyNewMenu[NM_OPENPOINTS].nm_CommKey = MyGetMsg(MSG_NM_OPENPOINTS_S);
MyNewMenu[NM_SAVE].nm_Label = MyGetMsg(MSG_NM_SAVE);
MyNewMenu[NM_SAVE].nm_CommKey = MyGetMsg(MSG_NM_SAVE_S);
MyNewMenu[NM_SAVEAS].nm_Label = MyGetMsg(MSG_NM_SAVEAS);
MyNewMenu[NM_SAVEAS].nm_CommKey = MyGetMsg(MSG_NM_SAVEAS_S);
MyNewMenu[NM_ABOUT].nm_Label = MyGetMsg(MSG_NM_ABOUT);
MyNewMenu[NM_EXITPOINTS].nm_Label = MyGetMsg(MSG_NM_EXITPOINTS);
MyNewMenu[NM_QUIT].nm_Label = MyGetMsg(MSG_NM_QUIT);
MyNewMenu[NM_QUIT].nm_CommKey = MyGetMsg(MSG_NM_QUIT_S);
MyNewMenu[NM_PPREVIEW].nm_Label = MyGetMsg(MSG_NM_PPREVIEW);
MyNewMenu[NM_EDIT].nm_Label = MyGetMsg(MSG_NM_EDIT);
MyNewMenu[NM_ADDGRID].nm_Label = MyGetMsg(MSG_NM_ADDGRID);
MyNewMenu[NM_ADDGRID].nm_CommKey = MyGetMsg(MSG_NM_ADDGRID_S);
MyNewMenu[NM_TRIANGULATE].nm_Label = MyGetMsg(MSG_NM_TRIANGULATE);
MyNewMenu[NM_TRIANGULATE].nm_CommKey = MyGetMsg(MSG_NM_TRIANGULATE_S);
MyNewMenu[NM_FRAME].nm_Label = MyGetMsg(MSG_NM_FRAME);
MyNewMenu[NM_FIRST].nm_Label = MyGetMsg(MSG_NM_FIRST);
MyNewMenu[NM_FIRST].nm_CommKey = MyGetMsg(MSG_NM_FIRST_S);
MyNewMenu[NM_PREVIOUS].nm_Label = MyGetMsg(MSG_NM_PREVIOUS);
MyNewMenu[NM_PREVIOUS].nm_CommKey = MyGetMsg(MSG_NM_PREVIOUS_S);
MyNewMenu[NM_GOTO].nm_Label = MyGetMsg(MSG_NM_GOTO);
MyNewMenu[NM_GOTO].nm_CommKey = MyGetMsg(MSG_NM_GOTO_S);
MyNewMenu[NM_NEXT].nm_Label = MyGetMsg(MSG_NM_NEXT);
MyNewMenu[NM_NEXT].nm_CommKey = MyGetMsg(MSG_NM_NEXT_S);
MyNewMenu[NM_LAST].nm_Label = MyGetMsg(MSG_NM_LAST);
MyNewMenu[NM_LAST].nm_CommKey = MyGetMsg(MSG_NM_LAST_S);
MyNewMenu[NM_EMODE].nm_Label = MyGetMsg(MSG_NM_EMODE);
MyNewMenu[NM_M_ONE].nm_Label = MyGetMsg(MSG_NM_M_ONE);
MyNewMenu[NM_M_ONE].nm_CommKey = MyGetMsg(MSG_NM_M_ONE_S);
MyNewMenu[NM_M_TWO].nm_Label = MyGetMsg(MSG_NM_M_TWO);
MyNewMenu[NM_M_TWO].nm_CommKey = MyGetMsg(MSG_NM_M_TWO_S);
MyNewMenu[NM_M_REL].nm_Label = MyGetMsg(MSG_NM_M_REL);
MyNewMenu[NM_M_REL].nm_CommKey = MyGetMsg(MSG_NM_M_REL_S);
MyNewMenu[NM_M_ADD].nm_Label = MyGetMsg(MSG_NM_M_ADD);
MyNewMenu[NM_M_ADD].nm_CommKey = MyGetMsg(MSG_NM_M_ADD_S);
MyNewMenu[NM_M_DEL].nm_Label = MyGetMsg(MSG_NM_M_DEL);
MyNewMenu[NM_M_DEL].nm_CommKey = MyGetMsg(MSG_NM_M_DEL_S);
MyNewMenu[NM_M_LNK].nm_Label = MyGetMsg(MSG_NM_M_LNK);
MyNewMenu[NM_M_LNK].nm_CommKey = MyGetMsg(MSG_NM_M_LNK_S);
MyNewMenu[NM_M_UNL].nm_Label = MyGetMsg(MSG_NM_M_UNL);
MyNewMenu[NM_M_UNL].nm_CommKey = MyGetMsg(MSG_NM_M_UNL_S);
MyNewMenu[NM_M_MOV].nm_Label = MyGetMsg(MSG_NM_M_MOV);
MyNewMenu[NM_M_MOV].nm_CommKey = MyGetMsg(MSG_NM_M_MOV_S);
MyNewMenu[NM_SETTINGS].nm_Label = MyGetMsg(MSG_NM_SETTINGS);
MyNewMenu[NM_CREATEICONS].nm_Label = MyGetMsg(MSG_NM_CREATEICONS);
MyNewMenu[NM_CHANGEPALETTE].nm_Label = MyGetMsg(MSG_NM_CHANGEPALETTE);
MyNewMenu[NM_CHANGEPALETTE].nm_CommKey = MyGetMsg(MSG_NM_CHANGEPALETTE_S);
MyNewMenu[NM_ZOOM].nm_Label = MyGetMsg(MSG_NM_ZOOM);
MyNewMenu[NM_ZOOM].nm_CommKey = MyGetMsg(MSG_NM_ZOOM_S);
MyNewMenu[NM_OPENMODE].nm_Label = MyGetMsg(MSG_NM_OPENMODE);
MyNewMenu[NM_ILBMALWAYS].nm_Label = MyGetMsg(MSG_NM_ILBMALWAYS);
MyNewMenu[NM_ILBMIFILBM].nm_Label = MyGetMsg(MSG_NM_ILBMIFILBM);
MyNewMenu[NM_ILBMIFCOLOURS].nm_Label = MyGetMsg(MSG_NM_ILBMIFCOLOURS);
MyNewMenu[NM_REMAP].nm_Label = MyGetMsg(MSG_NM_REMAP);
MyNewMenu[NM_ILBMOPAL].nm_Label = MyGetMsg(MSG_NM_ILBMOPAL);
MyNewMenu[NM_SCREEN].nm_Label = MyGetMsg(MSG_NM_SCREEN);
MyNewMenu[NM_CUSTOM].nm_Label = MyGetMsg(MSG_NM_CUSTOM);
MyNewMenu[NM_CDEPTH].nm_Label = MyGetMsg(MSG_NM_CDEPTH);
MyNewMenu[NM_SPREVIEW].nm_Label = MyGetMsg(MSG_NM_SPREVIEW);
MyNewMenu[NM_ICONSP].nm_Label = MyGetMsg(MSG_NM_ICONSP);
MyNewMenu[NM_KEEPS].nm_Label = MyGetMsg(MSG_NM_KEEPS);
MyNewMenu[NM_LOADS].nm_Label = MyGetMsg(MSG_NM_LOADS);
MyNewMenu[NM_SAVES].nm_Label = MyGetMsg(MSG_NM_SAVES);
MyNewMenu[NM_SAVESAS].nm_Label = MyGetMsg(MSG_NM_SAVESAS);
MyNewMenu[NM_ICONSR].nm_Label = MyGetMsg(MSG_NM_ICONSR);
MyNewMenu[NM_DX].nm_Label = MyGetMsg(MSG_NM_DX);
MyNewMenu[NM_DY].nm_Label = MyGetMsg(MSG_NM_DY);
MyNewMenu[NM_LOADSCRIPT].nm_Label = MyGetMsg(MSG_NM_LOADSCRIPT);
MyNewMenu[NM_PRESCRIPT].nm_Label = MyGetMsg(MSG_NM_PRESCRIPT);
MyNewMenu[NM_POSTSCRIPT].nm_Label = MyGetMsg(MSG_NM_POSTSCRIPT);
MyNewMenu[NM_DEPTH].nm_Label = MyGetMsg(MSG_NM_DEPTH);
MyNewMenu[NM_MODE].nm_Label = MyGetMsg(MSG_NM_MODE);
MyNewMenu[NM_MODE1].nm_Label = MyGetMsg(MSG_NM_MODE1);
MyNewMenu[NM_MODE2].nm_Label = MyGetMsg(MSG_NM_MODE2);
MyNewMenu[NM_MODE4].nm_Label = MyGetMsg(MSG_NM_MODE4);
MyNewMenu[NM_MODE8].nm_Label = MyGetMsg(MSG_NM_MODE8);
MyNewMenu[NM_MODE16].nm_Label = MyGetMsg(MSG_NM_MODE16);
MyNewMenu[NM_SAVEFORMAT].nm_Label = MyGetMsg(MSG_NM_SAVEFORMAT);
MyNewMenu[NM_ILBM24].nm_Label = MyGetMsg(MSG_NM_ILBM24);
MyNewMenu[NM_OPAL24].nm_Label = MyGetMsg(MSG_NM_OPAL24);
MyNewMenu[NM_OPAL24T].nm_Label = MyGetMsg(MSG_NM_OPAL24T);
MyNewMenu[NM_OPAL24F].nm_Label = MyGetMsg(MSG_NM_OPAL24F);
MyNewMenu[NM_OPAL24FT].nm_Label = MyGetMsg(MSG_NM_OPAL24FT);
MyNewMenu[NM_OPALJPEG].nm_Label = MyGetMsg(MSG_NM_OPALJPEG);
MyNewMenu[NM_OPALJPEGT].nm_Label = MyGetMsg(MSG_NM_OPALJPEGT);
MyNewMenu[NM_PBM].nm_Label = MyGetMsg(MSG_NM_PBM);
MyNewMenu[NM_BW16].nm_Label = MyGetMsg(MSG_NM_BW16);
MyNewMenu[NM_BW256].nm_Label = MyGetMsg(MSG_NM_BW256);
MyNewMenu[NM_HAM6].nm_Label = MyGetMsg(MSG_NM_HAM6);
MyNewMenu[NM_HAM8].nm_Label = MyGetMsg(MSG_NM_HAM8);
MyNewMenu[NM_DCTV3].nm_Label = MyGetMsg(MSG_NM_DCTV3);
MyNewMenu[NM_DCTV4].nm_Label = MyGetMsg(MSG_NM_DCTV4);
MyNewMenu[NM_QUALITY].nm_Label = MyGetMsg(MSG_NM_QUALITY);
MyNewMenu[NM_SCREENR].nm_Label = MyGetMsg(MSG_NM_SCREENR);
MyNewMenu[NM_ANTIALIAS].nm_Label = MyGetMsg(MSG_NM_ANTIALIAS);
MyNewMenu[NM_INTEGER].nm_Label = MyGetMsg(MSG_NM_INTEGER);
MyNewMenu[NM_RESETD].nm_Label = MyGetMsg(MSG_NM_RESETD);
MyNewMenu[NM_LASTS].nm_Label = MyGetMsg(MSG_NM_LASTS);
MyNewMenu[NM_RESTORE].nm_Label = MyGetMsg(MSG_NM_RESTORE);
MyNewMenu[NM_HELP].nm_Label = MyGetMsg(MSG_NM_HELP);
TSMorphTop = Scr->BarHeight + 1;
wtop = TSMorphTop;
ComputeFont( TSMorphWidth, TSMorphHeight );
ww = ComputeX( TSMorphWidth );
wh = ComputeY( TSMorphHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &TSMorphGList )))
return( 1L );
// If no reqtools then no animated morphs (so remove from cycle gadget)
// purely because we need the Frame requester
if (!ReqToolsBase) {
SinglePictureLabels[2] = NULL;
}
for( lc = 0, tc = 0; lc < TSMorph_CNT; lc++ ) {
CopyMem((char * )&TSMorphNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
if ( TSMorphGTypes[ lc ] != GENERIC_KIND ) {
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
}
// Save gadget position/size for help key
Rect[lc].MinX = ng.ng_LeftEdge;
Rect[lc].MinY = ng.ng_TopEdge;
Rect[lc].MaxX = ng.ng_LeftEdge + ng.ng_Width;
Rect[lc].MaxY = ng.ng_TopEdge + ng.ng_Height;
TSMorphGadgets[ lc ] = g = CreateGadgetA((ULONG)TSMorphGTypes[ lc ], g, &ng, ( struct TagItem * )&TSMorphGTags[ tc ] );
if ( TSMorphGTypes[ lc ] == GENERIC_KIND ) {
g->Flags |= GFLG_GADGIMAGE | GFLG_GADGHIMAGE;
g->Activation |= GACT_RELVERIFY;
g->GadgetRender = (APTR)getImage;
g->SelectRender = (APTR)getImage;
}
while( TSMorphGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
// update menus based on current settings
UpdateMenuDefs();
// non standard stuff, the settings menu is set up based on the global settings menu items
if ( ! ( TSMorphMenus = CreateMenus( TSMorphNewMenu, TAG_DONE )))
return( 3L );
if ( ! ( TSMorphMenus1 = (struct MenuItem *)CreateMenus( &(MyNewMenu[NM_CREATEICONS]) , TAG_DONE )))
return( 3L );
LayoutMenus( TSMorphMenus, VisualInfo,
GTMN_NewLookMenus,TRUE,
TAG_DONE );
TSMorphMenus->NextMenu->FirstItem = TSMorphMenus1;
LayoutMenuItems(TSMorphMenus1, VisualInfo,
GTMN_Menu,TSMorphMenus->NextMenu,
GTMN_NewLookMenus,TRUE,
TAG_DONE );
TSMorphZoom[0] = TSMorphZoom[1] = 0;
TSMorphZoom[2] = ww + OffX + Scr->WBorRight;
TSMorphZoom[3] = Rect[GDX_Help].MaxY + Scr->WBorBottom + 2;
#define GADGETUP IDCMP_GADGETUP
// This is used in the 2.02 versions of BUTTONIDCMP etc.
// But is not defined as IOBSOLETE stuff is not included
if ( ! ( TSMorphWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, IDCMP_GADGETUP|NUMBERIDCMP|BUTTONIDCMP|CHECKBOXIDCMP|STRINGIDCMP|
INTEGERIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_RAWKEY|IDCMP_VANILLAKEY|
IDCMP_MENUHELP|IDCMP_REFRESHWINDOW|IDCMP_GADGETHELP|IDCMP_MOUSEMOVE,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH,
WA_Gadgets, TSMorphGList,
WA_Title, TSMorphWdt,
WA_ScreenTitle, "TSMorph ©1993/94 Topicsave Limited",
WA_PubScreen, Scr,
WA_Zoom, TSMorphZoom,
WA_AutoAdjust, TRUE,
WA_PubScreenFallBack, TRUE,
WA_MenuHelp, TRUE,
WA_NewLookMenus,TRUE,
TAG_DONE )))
return( 4L );
// switch on gadget help if release 3.0+
if (IntuitionBase->LibNode.lib_Version > 38) {
HelpControl(TSMorphWnd,HC_GADGETHELP);
}
SetMenuStrip( TSMorphWnd, TSMorphMenus );
GT_RefreshWindow( TSMorphWnd, NULL );
ScreenToFront(Scr);
return( 0L );
}
void CloseTSMorphWindow( void )
{
// Free menus - not entirely sure if need (or should) do in two bits
if ( TSMorphMenus ) {
if (TSMorphWnd) {
ClearMenuStrip( TSMorphWnd );
}
TSMorphMenus->NextMenu->FirstItem = NULL;
FreeMenus( TSMorphMenus );
TSMorphMenus = NULL;
}
if (TSMorphMenus1) {
FreeMenus( (struct Menu *)TSMorphMenus1 );
TSMorphMenus1 = NULL;
}
if ( TSMorphWnd ) {
CloseWindow( TSMorphWnd );
TSMorphWnd = NULL;
}
if ( TSMorphGList ) {
FreeGadgets( TSMorphGList );
TSMorphGList = NULL;
}
}
int HandleGridRequestIDCMP( void )
{
struct IntuiMessage *m;
int (*func)(void);
BOOL running = TRUE;
ULONG HNum;
while( m = GT_GetIMsg( GridRequestWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&GridRequestMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( GridRequestMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( GridRequestWnd );
GT_EndRefresh( GridRequestWnd, TRUE );
break;
case IDCMP_CLOSEWINDOW:
running = GridRequestCloseWindow();
break;
case IDCMP_VANILLAKEY:
running = GridRequestVanillaKey();
break;
case IDCMP_RAWKEY:
running = GridRequestRawKey();
break;
case IDCMP_GADGETUP:
func = (FPTR *)(( struct Gadget * )GridRequestMsg.IAddress )->UserData;
running = func();
break;
// gadgethelp - see above
case IDCMP_GADGETHELP:
if (GridRequestMsg.IAddress == NULL) {
HNum = 0;
}
else {
if (GridRequestMsg.IAddress == GridRequestWnd) {
HNum = H_RAG;
}
else {
switch (((struct Gadget *)GridRequestMsg.IAddress)->GadgetType &0xf0) {
case GTYP_WDRAGGING:
HNum = H_RAG;
break;
case GTYP_WUPFRONT:
HNum = H_RAGGDE;
break;
case GTYP_CLOSE:
HNum = H_RAGGCL;
break;
case 0:
switch (((struct Gadget *)GridRequestMsg.IAddress)->GadgetID) {
case GD_XCells:
HNum = H_RAGGX;
break;
case GD_YCells:
HNum = H_RAGGY;
break;
case GD_OK:
HNum = H_RAGGOK;
break;
case GD_Cancel:
HNum = H_RAGGCA;
break;
default:
HNum = H_RAG;
break;
}
break;
default:
HNum = H_RAG;
break;
}
}
}
if (HNum) {
if (GHelp) {
help(HNum);
}
else {
ihelp(HNum);
}
}
break;
}
}
return( (int) running );
}
int OpenGridRequestWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = GridRequestLeft, wtop = GridRequestTop, ww, wh;
ComputeFont( GridRequestWidth, GridRequestHeight );
ww = ComputeX( GridRequestWidth );
wh = ComputeY( GridRequestHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &GridRequestGList )))
return( 1L );
for( lc = 0, tc = 0; lc < GridRequest_CNT; lc++ ) {
CopyMem((char * )&GridRequestNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
// save position and size for help key
GRect[lc].MinX = ng.ng_LeftEdge;
GRect[lc].MinY = ng.ng_TopEdge;
GRect[lc].MaxX = ng.ng_LeftEdge + ng.ng_Width;
GRect[lc].MaxY = ng.ng_TopEdge + ng.ng_Height;
GridRequestGadgets[ lc ] = g = CreateGadgetA((ULONG)GridRequestGTypes[ lc ], g, &ng, ( struct TagItem * )&GridRequestGTags[ tc ] );
while( GridRequestGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( GridRequestWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, INTEGERIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_RAWKEY|IDCMP_VANILLAKEY|
IDCMP_REFRESHWINDOW|IDCMP_GADGETHELP|IDCMP_MOUSEMOVE,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, GridRequestGList,
WA_Title, GridRequestWdt,
WA_ScreenTitle, "TSMorph",
WA_PubScreen, Scr,
WA_AutoAdjust, TRUE,
TAG_DONE )))
return( 4L );
// switch on help control if release 3.0+
if (IntuitionBase->LibNode.lib_Version > 38) {
HelpControl(GridRequestWnd,HC_GADGETHELP);
}
GT_RefreshWindow( GridRequestWnd, NULL );
return( 0L );
}
void CloseGridRequestWindow( void )
{
if ( GridRequestWnd ) {
CloseWindow( GridRequestWnd );
GridRequestWnd = NULL;
}
if ( GridRequestGList ) {
FreeGadgets( GridRequestGList );
GridRequestGList = NULL;
}
}
int HandleProgressIDCMP( void )
{
struct IntuiMessage *m;
BOOL running = TRUE;
while( m = GT_GetIMsg( ProgressWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&ProgressMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( ProgressMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( ProgressWnd );
GT_EndRefresh( ProgressWnd, TRUE );
break;
}
}
return( (int) running );
}
int OpenProgressWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = ProgressLeft, wtop = ProgressTop, ww, wh;
ComputeFont( ProgressWidth, ProgressHeight );
ww = ComputeX( ProgressWidth );
wh = ComputeY( ProgressHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &ProgressGList )))
return( 1L );
for( lc = 0, tc = 0; lc < Progress_CNT; lc++ ) {
CopyMem((char * )&ProgressNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
ProgressGadgets[ lc ] = g = CreateGadgetA((ULONG)ProgressGTypes[ lc ], g, &ng, ( struct TagItem * )&ProgressGTags[ tc ] );
while( ProgressGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( ProgressWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, TEXTIDCMP|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_SMART_REFRESH,
WA_Gadgets, ProgressGList,
WA_Title, ProgressWdt,
WA_ScreenTitle, "TSMorph ©1993/94 Topicsave Limited",
WA_PubScreen, Scr,
TAG_DONE )))
return( 4L );
// Wait pointer
SetPointer(ProgressWnd, BusyPointerData, 16, 16, -6, 0);
GT_RefreshWindow( ProgressWnd, NULL );
return( 0L );
}
void CloseProgressWindow( void )
{
if ( ProgressWnd ) {
CloseWindow( ProgressWnd );
ProgressWnd = NULL;
}
if ( ProgressGList ) {
FreeGadgets( ProgressGList );
ProgressGList = NULL;
}
}